package com.alibaba.dubbo.registry;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class CommonConfiguration {
	private static final ConcurrentHashMap<String, String> Configs = new ConcurrentHashMap<String, String>();

	public static void updateConfigs(List<String> urls) {
		ConcurrentHashMap<String, String> newConfigs = new ConcurrentHashMap<String, String>();

		for (String url : urls) {
			String[] pair = url.split("=");
			if(pair.length == 2){
				newConfigs.put(pair[0], pair[1]);
			}
		}

		Configs.clear();
		Configs.putAll(newConfigs);
	}

	public static String getValue(String key) {
		return Configs.get(key);
	}

	public static Boolean getBoolean(String key) {
		return "true".equalsIgnoreCase(getValue(key));
	}
}
